<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML>  
<html>
<head>
<meta charset="utf-8"/>
<script type="text/javascript">
	function $$(id) {
		return document.getElementById(id);
	}
	


// 	// 跨文档消息传输
// 	var win2 = window.open('webtx2.jsp');
	
	
// 	window.addEventListener('message', function(e) {
// 		alert(e.data);
// 	});
	
// 	function send() {
// // 		var win2 = window.frames['webtx2'];
// 		win2.postMessage($$('msg').value, 'http://192.168.111.197:8088/z_mytest/jsp/webtx2.jsp');
// 	}
	
	
	// webSocket
	var ws = new WebSocket('ws://192.168.111.197:8888');
	
	function send() {
		ws.send($$('msg').value);
	}
	
	function close() {
		ws.close();
	}
	
	ws.onopen = function(e){
		alert('open');
	};
	
	ws.onmessage = function(e){
		alert(e.data);
	};
	
	ws.onclose = function(e) {
		alert('close');
	};
	
	
</script>

</head>
<body>
	<textarea rows="5" cols="50" id="msg"></textarea><br/>
  	<button onclick="send()">send</button>
  	<button onclick="close()">close</button>
    
    
<!--     <iframe src="webtx2.jsp" name="webtx2"></iframe> -->
</body>
</html>